home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / CIS_GAME.ARJ / QSBSB1.THD < prev    next >
Text File  |  1993-07-01  |  35KB  |  721 lines

  1. ________________________ Subj: Playing Sound on PC ________________________
  2.  
  3. Fm: Mark Betz/GD SL 76605,2346                 # 181875 
  4. To: Intergalactic, Dev., Inc 76356,2172 (X)    Date: 27-Jun-92  13:08:37
  5.  
  6. A couple of choices, Ezra: You can roll your own. This will involve creating
  7. a low-level driver (probably driven off the timer interrupt). Or, you can
  8. purchase a library, such as John Ratcliff's DIGPAK, which supports a variety
  9. of sound devices. Adlib .ROL, and CMS .CMF files are essentially MIDI files
  10. with restricted MIDI event/message recognition. The files are parsed, and the
  11. driver will turn notes on and off at the proper times. I've done low-level
  12. programming to the FM chip, but haven't had occasion to parse MIDI files yet.
  13. I imagine it's not trivial programming, as the timing must be fairly precise.
  14.                                                        --Mark
  15. ...........................................................................
  16.  
  17. Fm: Mark Betz/GD SL 76605,2346                 # 181904 
  18. To: Sarwan Narine 76675,164                    Date: 27-Jun-92  14:52:53
  19.  
  20. Hi, Sarwan. There are several routes you can go. The DSP chip on the
  21. Soundblaster (and TB) can be driven via DMA, freeing the CPU for other
  22. business. Or it can be "pumped" using the timer to send data to it at the
  23. correct speed. Whichever route you take will be fairly complex and require
  24. low-level programming to the sound card hardware. A third alternative is to
  25. use the supplied drivers, which can be loaded and accessed by your program,
  26. and a fourth is to purchase a sound devide library like DIGPAK. For
  27. alternatives 1, 2, and 3, get yourself a copy of the Sound Blaster
  28. Developer's Kit from CMS. It's not great, but you can use it to get the job
  29. done, and there is good information on the low-level interfaces to the
  30. hardware. 
  31.                Creative Labs, Inc.
  32.                2050 Duane Ave.
  33.                Santa Clara, CA 95054
  34.  
  35. Sorry! I don't have the phone number at hand.
  36.  
  37.                                                        --Mark
  38. ...........................................................................
  39.  
  40. Fm: Rasch H Young 70511,2043                   # 182020 
  41. To: Sarwan Narine 76675,164                    Date: 27-Jun-92  22:24:51
  42.  
  43. Sarwan,
  44.  
  45. I have both the Sound blaster SDK and DIgPak. I believe DIGPAK pro is a
  46. better product at a lower price $69.95. The Audio Solution 1-314-567-0267.
  47.  
  48. Rasch
  49.  
  50. ________________________ Subj: Sound card detection ________________________
  51.  
  52. Fm: Sarwan Narine 76675,164                    # 185506 
  53. To: All                                        Date: 08-Jul-92  02:47:07
  54.  
  55. How do you detect the presence of a sound card in a PC system?
  56. ...........................................................................
  57.  
  58. Fm: Mark Betz/GD SL 76605,2346                 # 187160 
  59. To: Sarwan Narine 76675,164 (X)                Date: 12-Jul-92  19:54:16
  60.  
  61. Hi, Sarwan. Here is a function (and support functions) for detecting the
  62. presence of the FM music chip. If DetectFM() returns true then the chip is
  63. present in the system. This tells you that you have either an SB, Adlib, or
  64. one of the SB clones. You can further distinguish between the SB and Adlib,
  65. but more on that later. The first function we need is a function to send data
  66. to the FM chip registers. Here's one in assembler...
  67.  
  68. _SetReg    proc far
  69.    push    bp
  70.    mov     bp, sp
  71.    push    ax
  72.    push    cx
  73.    push    dx
  74.    xor     ax, ax
  75.    mov     dx, 0388h              ; FM Address Register Port
  76.    mov     al, byte ptr [bp + 6]  ; get the register into al
  77.    out     dx, al                 ; write it to the Address Reg.
  78.    mov     cx, 7                  ; need to wait 3.3 microsecs here...
  79.  
  80. wait1:                            ; which we'll do by reading the
  81.    in      al, dx                 ; status reg 7 times
  82.    loop    wait1
  83.    mov     al, byte ptr [bp + 8]  ; get the data byte into al
  84.    inc     dx                     ; point dx to the Data Register Port
  85.    out     dx, al                 ; write the data
  86.    mov     cx, 35                 ; need to wait 23 microsecs here...
  87. wait2:                            ; read the port 35 times
  88.    in      al, dx
  89.    loop    wait2
  90.    pop     dx
  91.    pop     cx
  92.    pop     ax
  93.    pop     bp
  94.    retf
  95. _SetReg    endp
  96.  
  97. The techniques for this come right out of the Sblaster Developer's Kit, which
  98. I recommend. It's not the job I wish it was, but it's all that is available
  99. as far as I know. I haven't seen any books on the topic. Anyway, the SBDK is
  100. adequate if you're willing to go mining yourself for the stuff it doesn't
  101. give you. Call CMS at 408-986-1461 if you're interested. Now that we have the
  102. function to set the registers we need the the function that detects the card.
  103. This writes to some registers, which are referred to in the calls to
  104. SetReg(). I won't explain what they do, as this is a topic for a long
  105. magazine article, or chapter in a book. 
  106.  
  107.  // DetectFM() returns true if the FM chip is detected in the system, or
  108.  // false if it is not.
  109.  
  110. bool DetectFM() {
  111.    byte stat1;
  112.    byte stat2;
  113.    byte result = 0;
  114.  
  115.    SetReg( 0x1, 0 );                     // initialize test register
  116.    SetReg( 0x4, 0x60 );                  // reset both timers
  117.    SetReg( 0x4, 0x80 );                  // enable timer interrupts
  118.    stat1 = inportb( 0x388 );             // read the status port
  119.    SetReg( 0x2, 0xff );                  // write ff to the timer 1 count
  120.    SetReg( 0x4, 0x21 );                  // start timer 1
  121.    Wait( 90 );                           // wait 90 microseconds
  122.    stat2 = inportb( 0x388 );             // read the status port
  123.    SetReg( 0x4, 0x60 );                  // reset both timers
  124.    SetReg( 0x4, 0x80 );                  // enable timer interrupts
  125.    stat1 &= 0xe0;                        // stat1 should be zero after
  126.    if ( !stat1 ) {                       // ANDing it with 0xe0
  127.           stat2 &= 0xe0;                     // stat2 should be 0xc0 after
  128.           if ( stat2 == 0xc0 ) {             // ANDing it with 0xe0
  129.                  result++;                       // if so, return true
  130.           }
  131.    }
  132. return( result );
  133. }
  134.  
  135. Oh, and I see we have one other support function required. Wait() simply
  136. waits for the specified number of microseconds, approximately. You can
  137. substitute your own function if you like, but here is the technique used in
  138. the SBDK. I would probably implement it as a more accurate timer-based
  139. function, instead of reading the bus the way they do, but I haven't had the
  140. time to re-do it. 
  141.  
  142.  // Wait() approximates a wait in microseconds by reading the bus. Called
  143.  // only by the DetectFM() function.
  144.  
  145. void Wait( int howLong )
  146.    {
  147.    byte dummy;
  148.    int reads = howLong / 10;
  149.    reads *= 16;
  150.    do
  151.          {
  152.          dummy = inportb( 0x388 );
  153.          reads--;
  154.          } while ( reads );
  155.    return;
  156.    }
  157.  
  158. One last thing. I mentioned that you can tell whether it's a Sound Blaster FM
  159. chip you're detecting. This is because the SB maps the chip to ports 0x2x8
  160. and 0x2x9 (where x is the base port address of the SB). The Adlib standard is
  161. to map the chip to 0x388 and 0x389. To maintain compatibility the SB decodes
  162. the chip here as well. So if you can find the chip at both locations it's a
  163. Sound Blaster. If not it's an Adlib.
  164.  
  165. ________________________ Subj: Sound card I/O ports ________________________
  166.  
  167. Fm: Sarwan Narine 76675,164                    # 187955 
  168. To: Mark Betz/GD SL 76605,2346 (X)             Date: 15-Jul-92  02:46:26
  169.  
  170. Mark, thank you for that informative and complete example of how to detect a
  171. sound card.
  172.  
  173. On my ThunderBoard sound card I can set the I/O port addresses to 210h, 220h,
  174. 230h, 240h, 250h, or 260h.  How do you find out where the I/O ports are?  The
  175. documentation I have says that only ports 2n6, 2n8, 2n9, 2nA, 2nC, and 2nE
  176. are used, where n is 1,2,3,4,5,or 6.  What are these ports? A brief
  177. description of each port would be appreciated.  Thank you.
  178.  
  179.  --Sarwan-
  180. ...........................................................................
  181.  
  182. Fm: Mark Betz/GD SL 76605,2346                 # 188069 
  183. To: Sarwan Narine 76675,164                    Date: 15-Jul-92  15:12:08
  184.  
  185. Hi, Sarwan. According to my reference the SB uses the addresses from 2n0H to
  186. 2nFH where n is in the range 1 to 6 inclusive. Here is a map of the ports:
  187.  
  188.      PORT         WHAT IS IT                           WHAT CAN I DO TO IT
  189.      ------------------------------------------------------------------
  190.      200H-207H    ANALOG JOYSTICK                      READ/WRITE
  191.      2n0H         C/MS MUSIC VOICE 1-6 DATA PORT       WRITE ONLY
  192.      2n1H         C/MS MUSIC VOICE 1-6 REGISTER PORT   WRITE ONLY
  193.      2n2H         C/MS MUSIC VOICE 7-12 DATA PORT      WRITE ONLY
  194.      2n3H         C/MS MUSIC VOICE 7-12 REGISTER PORT  WRITE ONLY
  195.      2n6H         DSP RESET                            WRITE ONLY
  196.      2n8H         FM MUSIC STATUS PORT                 READ
  197.      2n8H         FM MUSIC REGISTER PORT               WRITE
  198.      2n9H         FM MUSIC DATA PORT                   WRITE ONLY
  199.      2nAH         DSP READ DATA PORT                   READ ONLY
  200.      2nCH         DSP WRITE DATA OR COMMAND            WRITE
  201.      2nCH         DSP WRITE BUFFER STATUS (BIT 7)      READ
  202.      2nEH         DSP DATA AVAILABLE STATUS (BIT 7)    READ ONLY
  203.  
  204. The C/MS music voice ports are available only on SB cards with these chips
  205. installed. The FM music ports can also be accessed at ports 388H and 389H
  206. (for Adlib compatibility).
  207.  
  208.                                                 --Mark
  209. ...........................................................................
  210.  
  211. Fm: Mark Betz/GD SL 76605,2346                 # 189758 
  212. To: Sarwan Narine 76675,164                    Date: 20-Jul-92  16:21:03
  213.  
  214. >> ...how do you find the value of n
  215.  
  216. Well, there are a couple of options. You can ask the user, which is the route
  217. most apps take. You can rely on Creative's SBLASTER environment variable
  218. (NOT!). Or you can perform the test I outlined for each possible port.
  219.  
  220.                                                         --Mark
  221.  
  222. _________________________ Subj: Playing .VOC files _________________________
  223.  
  224. Fm: Sarwan Narine 76675,164                    # 191206 
  225. To: All                                        Date: 24-Jul-92  04:12:35
  226.  
  227. How do you output an 8-bit sample of a .VOC file through the SoundBlaster or
  228. AdLib sound card?  Also, is there any on-line information on using a DMA
  229. channel or timer to playback sound?  I'm looking for assembly source code. 
  230. Thank you.
  231.  
  232. --Sarwan-
  233. ...........................................................................
  234.  
  235. Fm: Mark Betz/GD SL 76605,2346                 # 191420 
  236. To: Sarwan Narine 76675,164                    Date: 24-Jul-92  20:02:33
  237.  
  238. Hello again, Sarwan. If you have the manual for the Sound Blaster you will
  239. find a simple reference to the functions in the CT-VOICE.DRV driver supplied
  240. on disk with the card. This driver is the simplest way to pump data to the
  241. dsp chip, since it provides you with some high level control constructs.
  242. Alternatively you can write directly to the chip. The DSP chip is actually
  243. very simple, being sort of like a pipe with one end attached to memory, and
  244. the other to the speaker system. All you really have to do is pour data into
  245. it at the proper rate. You can do this either by pumping it through with the
  246. timer interrupt, or using the DMA channel 1. I strongly suggest contacting
  247. Creative Labs and buying the SB developer's kit.
  248.  
  249. If you simply want to get sound support, then I suggest the DIGPAK library.
  250. Leave mail or a message here for John Ratcliff 70253,3237. The have a lib for
  251. sale at a very good price which supports midi and digitized sound on just
  252. about every device you can imagine, if half of what I've heard is true.
  253.  
  254.                                                         --Mark
  255. ...........................................................................
  256.  
  257. Fm: James Mayes 71151,3037                     # 203245 
  258. To: Mark Betz/GD SL 76605,2346 (X)             Date: 21-Aug-92  18:04:08
  259.  
  260. I also have another question.  I recall your recently discussing with
  261. someone else your experience programming the Soundblaster by loading the
  262. driver into memory and then making calls to the driver with the correct
  263. registers initialized properly.  I have always used the SB Development Kit
  264. by Creative, but I am curious about the direct method and I was wondering
  265. about a few things.  (BTW, I am strictly talking about digitized voice and
  266. the CT-VOICE driver)
  267.  
  268.     1.  The SBK says you need to load the driver at offset 0 of some
  269.     segment, load the registers and make a far CALL to that seg,off.  What
  270.     would be the syntax for making this call from C given a far pointer to
  271.     the buffer containing the driver?
  272.  
  273.     2.  The CT-VOICE driver doesn't include any functions for detecting the
  274.     SB card or scanning for the correct interrupt number.  Are you aware of
  275.     any good sources for this info?
  276.  
  277.     3.  Do you know if there would be a problem with distributing the
  278.     CT-VOICE driver file with a game that used this approach?  (I don't
  279.     think there should be, but those kind of questions always worry me.)
  280. ...........................................................................
  281.  
  282. Fm: Mark Betz/GD SL 76605,2346                 # 203304 
  283. To: James Mayes 71151,3037 (X)                 Date: 21-Aug-92  19:47:00
  284.  
  285. Hi, James. I'm not sure what you mean by "the direct method". Is there some
  286. other way to access CT-VOICE.DRV explained in the SDK? Basically you have to
  287. get the driver into memory first. That requires allocating memory for it, and
  288. reading it in. The twist is that you have to allocate an extra paragraph, or
  289. 16 bytes, so that you can force the offset to 0. the new keyword and alloc()
  290. functions usually return an offset of 4, and in any case you can't guarantee
  291. that the offset will be 0. Allocate an extra paragraph, and do a little
  292. segment/offset arithmetic to normalize the pointer (make sure to keep a copy
  293. of the original for use with free() or delete). 
  294.  
  295. Once you get the driver read into memory you can set the IRQ and port address
  296. directly. The offsets of these values are listed in the SDK, but anyway, they
  297. are right near the beginning of the CT-VOICE driver file; maybe offset 40h or
  298. thereabouts. As for finding out which values to use, you either have to ask
  299. the user, or test all possible combinations.
  300.  
  301. From that point on it's a simple matter of casting the driver buffer pointer
  302. to a pointer to function, and then making calls to it.
  303.  
  304. void* buf;                             // pointer to buffer void (*drvr)();
  305. // function pointer buf = new byte[sizeof_driver];         // alloc driver
  306. memory drvr = (void(*)()) buf;                // not sure about this cast!
  307. ...........................................................................
  308.  
  309. Fm: Sarwan Narine 76675,164                    # 203407 
  310. To: All                                        Date: 22-Aug-92  02:06:32
  311.  
  312. Well, I've posted this question before, with unsucessful results.  So, I'll
  313. post it again -- because I like to aggravate people <g>.
  314.  
  315. OK, here it is:  How do you output an 8-bit sample to the SoundBlaster card? 
  316. Assume the SB is installed at 220h.  Thanks.
  317. ...........................................................................
  318.  
  319. Fm: Mark Betz/GD SL 76605,2346                 # 203510 
  320. To: Sarwan Narine 76675,164 (X)                Date: 22-Aug-92  13:39:16
  321.  
  322. Sarwan, if you're talking about driving the output from your application,
  323. then you are into several complex areas of hardware programming, including
  324. the interrupt controller, dma controller, and the dsp chip on the SB. I'll
  325. give you skeletal procedures for doing it with the driver, but you'll have to
  326. dig in your references for the details.
  327.  
  328. Using the driver:  1. Allocate ram for the driver on the heap. The driver
  329.                       needs to be loaded at offset 0 of a segment, so grab
  330.                       a paragraph more than you need, and do pointer math
  331.                       to force the offset to 0 and the seg to the largest
  332.                       possible value.
  333.                    2. Read the driver (CT-VOICE.DRV) into memory.
  334.                    3. Set a function pointer on the first byte of the driver
  335.  
  336.                    NOTE: to call a driver function set BX = the function no.,
  337.                    and set any other registers needed, then call the driver.
  338.                    4. Set the base I/O address. BX = 1, AX = base I/O addr.
  339.                    5. Set the dma interrupt. BX = 2, AX = dma interrupt no.
  340.                    6. Initialize the driver. BX = 3. Returns error code, AX.
  341.                                 AX = 0: driver init successful
  342.                                 AX = 1: bad driver version
  343.                                 AX = 2: I/O read/write failure
  344.                                 AX = 3: DMA interrupt failure
  345.                    7. Load the voice data into memory (see block structure)
  346.                    8. Turn the speaker on. BX = 4, AL != 0.
  347.                    9. Start voice output. BX = 6, ES:DI = voice data, returns
  348.                       error code, AX.
  349.                                 AX = 0: output successful
  350.                                 AX != 0: failure
  351.                    10. Turn speaker off. BX = 4, AL = 0.
  352.                    11. Terminate driver. BX = 9.
  353.  
  354. Note that the voice data you output must be in CMS .VOC format. This format
  355. uses a block structure, with each block of data preceeded by a header which
  356. identifies it to the driver. The only block-type you're concerned with at
  357. this point is the Voice Data Block. It looks like this:
  358.  
  359.                  byte 0  : type field = 01
  360.                       1-3: three bytes data block length (actual length - 2)
  361.                       4  : time constant = 256- (1000000 / sampling rate)
  362.                       5  : compress. (0: raw, 1: 4-bit, 2: 2.6-bit, 3: 2-bit)
  363.  
  364. Make sure one of these blocks is at the front of your voice data and
  365. initialized correctly. Once you start the voice output you'll get control of
  366. the processor back, and your program can continue.
  367. ...........................................................................
  368.  
  369. Fm: James Mayes 71151,3037                     # 203802 
  370. To: Mark Betz/GD SL 76605,2346 (X)             Date: 23-Aug-92  10:45:17
  371.  
  372.  
  373. Thanks a lot, Mark.  By "direct method" I simply meant writing my own code
  374. to access the driver rather than calling the ctvm_XXXX routines supplied
  375. with the SDK.  The longer I program, the worse my English becomes <g>.  The
  376. info you gave me was exactly what I was looking for.  I think I will give it
  377. all a try very soon.  Thanks for your help!!
  378. ...........................................................................
  379.  
  380. Fm: Sarwan Narine 76675,164                    # 207584 
  381. To: Mark Betz 76605,2346 (X)                   Date: 02-Sep-92  02:51:10
  382.  
  383. Hi Mark.  I haven't had much success with playing back a .VOC file thru the
  384. SoundBlaster.  Here's what I've got (assume SB installed at 220h):
  385.  
  386.                ; reset DSP
  387.  
  388.                OUT   226h, 1
  389.                OUT   226h, 0
  390.  
  391.                ; turn on the speaker
  392.  
  393.                OUT   22Ch, 0D1h
  394.  
  395.                ; playback loop
  396.  
  397. PLAYBACK_LOOP: OUT   22Ch, 10h
  398.                OUT   22Ch, SAMPLE
  399.                DELAY
  400.                LOOP  PLAYBACK_LOOP
  401.  
  402.                ; turn off the speaker
  403.  
  404.                OUT   22Ch, 0D3h
  405.  
  406. Hey kids, don't try this at home.  The above is "pseudo-code", don't try it
  407. on your assembler <g>.
  408.  
  409. OK, Mark, the above _occasionally_ outputs something resembling the .VOC file
  410. contents, although it sounds like it's played-back in slow-motion. Most of
  411. the times I get no output.  Any suggestions?
  412. ...........................................................................
  413.  
  414. Fm: Mark Betz/GD SL 76605,2346                 # 207964 
  415. To: Sarwan Narine 76675,164 (X)                Date: 02-Sep-92  23:34:56
  416.  
  417. Hi, Sarwan. The procedure outlined in the manual says that you must wait 3
  418. microseconds between the two steps of the DSP reset process. It could be that
  419. this is mandatory, and it could be intermittent because certain variances
  420. caused by a cache hit/non-hit or something are causing you to get a >= 3
  421. microsecond delay on some calls, and not on others. I'd specifically place
  422. the delay in the function. As for slow playback, that is almost certainly
  423. related to the speed with which you're sending the data to the DSP.
  424. ...........................................................................
  425.  
  426. Fm: Hans Peter Rushworth 100031,473            # 214082 
  427. To: Mark Betz/GD SL 76605,2346 (X)             Date: 17-Sep-92  10:08:04
  428.  
  429. >> The volume can be controlled by altering the sampled data in certain
  430. mathmatically precise ways that I do not know <g>.
  431.  
  432. It is much simpler than you think!
  433.  
  434. If the samples are simple signed amplitudes, then just multiply each 8-bit
  435. sample by a constant from 0 to 256, and use the top 8 bits of the result. If
  436. they are unsigned, convert to signed by subtracting 128 first, and adding 128
  437. afterwards. (you must use a signed multiply or equivalent shift operation).
  438. The output volume is not linearly related to the multiplier. A range of 0 1 2
  439. 4 8 16 32 ... (ie use shifts!) will give a more or less linear progressive
  440. increase in volume (ie half the amplitude is NOT half as loud). With low
  441. multipliers the quantisation error (hence noise) will be high, unfortunately.
  442. Only 8-bits are a bit limiting I'm afraid (pun intended), so for a finer
  443. variation in volume you may need find intermediate values for the multiplier.
  444. For example, the multiplier between 128 and 256 is 181, (not 192) which is
  445. found by taking 2^7.5 (2^7 is 128 and 2^8 is 256, so 2^7.5 is half way in
  446. between). 
  447.  
  448. You shouldn't simply add values as you suggest, since this will introduce
  449. high levels harmonic distortion, not what you want I suspect.
  450.  
  451. _______________________ Subj: Sound Blaster Effects _______________________
  452.  
  453. Fm: Jesse 76646,3302                           # 267987 
  454. To: all                                        Date: 26-Dec-92  15:32:45
  455.  
  456. Here's a thought, though it's either easy to do and has already been done, or
  457. it can't be done and hasn't [g]
  458.  
  459. Instead of worrying about .vocs for small sound effects like gunfire,
  460. explosions, engine noise, etc, couldn't we just create an instrument for each
  461. sound and dynamically "play" them as the game goes on?  I've only peeked at
  462. the FM-Organ thing that came with the SB, but I seem to recall it letting
  463. several instruments play at once.
  464. ...........................................................................
  465.  
  466. Fm: John W. Ratcliff 70253,3237                # 268036 
  467. To: Jesse 76646,3302                           Date: 26-Dec-92  17:43:38
  468.  
  469. Jesse,
  470.  
  471. >>just create an instrument for each sound and dynamically "play" them as the
  472. game goes on?
  473.  
  474. Yes it can be done. That is in fact how all sound effects are made in Ultima
  475. Underworld and a number of other games.   However, it is very difficult to
  476. do, has no analgy on non-FM synth devices, and digital sound effects are
  477. easier and sound better.  Plus I'm selling DigPak and people should definatly
  478. be doing digital effects from my point of view.  You can do all of you
  479. music/FX that way if you use the Audio Interface Library from Miles Design
  480. Inc.  However, AIL has a rather overwhelming API and is out of the price
  481. range of the small developer. 
  482.  
  483. John.
  484. ...........................................................................
  485.  
  486. Fm: Mark Betz/Ass't SysOp 76605,2346           # 268883 
  487. To: Jesse 76646,3302 (X)                       Date: 28-Dec-92  11:26:54
  488.  
  489. Hi, Jesse. I don't know how many people use digitized sound for engine
  490. noises. The engine is one area where a synth chip can do a fine job, so my
  491. approach has been to create the engine noises on the synth, leaving the
  492. sampled sound to be used for specific effects.
  493.  
  494. _____________________ Subj: Sound Blaster Programming _____________________
  495.  
  496. Fm: Everett Kaser (Sherlock) 70673,1547        # 310695 
  497. To: Vu Truong (Siliconis) 70242,3015 (X)       Date: 08-Mar-93  22:10:28
  498.  
  499. There's a file available from an FTP site on internet (and may be somewhere
  500. here on CIS) written by Jeffrey S. Lee for the Soundblaster Freedom Project.
  501. It's file name is usually SFP.ZIP.  It contains lots of good reference
  502. information regarding the Soundblaster (and Adlib) registers.  I have a
  503. couple of other files that I've snarfed off of internet that contain file
  504. formats for SBI files and CMF files.  If they're not already available in one
  505. of the libraries, and someone would point out the appropriate place for them,
  506. I'd be glad to upload them (on Tuesday, for a hamburger today <G>).
  507.  
  508. Everett
  509. ...........................................................................
  510.  
  511. Fm: Dan Corritore 70243,1110                   # 310714 
  512. To: Vu Truong (Siliconis) 70242,3015 (X)       Date: 08-Mar-93  22:36:29
  513.  
  514. I have the format here, but I'd rather not type the long descriptions that
  515. are on it. If you want more description, buy 'The Sound Blaster Book'--very
  516. useful, especially in the file-formats category.
  517.         Bytes   Description
  518.         0-3             File ID--       'SBI' followed by 0x1a
  519.         4-35            Instrument Name--name of instrument (ASCIIZ form)
  520.         36              Modulator sound properties
  521.         37              Carrier sound properties
  522.         38          Modulator volume
  523.         39              Carrier volume
  524.         40              Modulator attack/delay
  525.         41              Carrier attack/delay
  526.         42              Modulator sustain/release
  527.         43              Carrier sustain/release
  528.         44              Modulator waveform
  529.         45              Carrier waveform
  530.         46              Synthesis mode and phase shifting
  531.         47-51   Future use
  532. Sorry if the above does not appear in columns.. my software doesn't give a
  533. 'WYSIWYG' interface in messages. And also sorry that the above weren't very
  534. descriptive!
  535.         _Dan  
  536. ...........................................................................
  537.  
  538. Fm: Everett Kaser (Sherlock) 70673,1547        # 313151 
  539. To: Everett Kaser (Sherlock) 70673,1547        Date: 13-Mar-93  15:07:10
  540.  
  541. OK, here's the internet ftp sites for soundboard related stuff that I had at
  542. work and their directories:
  543.  
  544.  ftp.brad.ac.uk      misc/mod
  545.  saffron.inset.com   pub/unix/sound_drivers (access limited to 3:30pm-5:30am)
  546.  ftp.ulowell.edu     msdos/Sound/AdlibSB
  547.  wuarchive.wustl.edu mirrors3/garbo.uwasa.fi/sb
  548.  snake.mcs.kent.edu  pub/SB-Adlib
  549.  ccosun.caltech.edu  pub/heathh/sb
  550.  
  551. Good luck!  I hope you find what you want.
  552.  
  553. Everett
  554. ...........................................................................
  555.  
  556. Fm: Everett Kaser (Sherlock) 70673,1547        # 313152 
  557. To: Vu Truong (Siliconis) 70242,3015 (X)       Date: 13-Mar-93  15:07:30
  558.  
  559. Ok, I was unable to track down the file itself (that documents the .SBI file
  560. format) in my CAREFULLY arranged and METICULOUSLY indexed disk library <G>,
  561. so I typed in from a printed copy the section pertaining to the SBI format:
  562.  
  563. -----------------------------------------------------------------------
  564.  
  565. Sound Blaster Instruments File (SBI) Format:
  566. ----------------------------------------------
  567.  
  568. The SBFM driver programs the registers of the FM chips to synthesize the
  569. different instrument sound. Such register information is stored in the SBI
  570. file with one instrument per file.
  571.  
  572. The Sound Blaster IEDIT program allows users to define new instruments and
  573. store them in the SBI format.
  574.  
  575. The format of the SBI file is as follows:
  576.  
  577. Offset (hex):   Description: -------------
  578. ------------------------------------------
  579.  00 - 03     File ID (ASCII string "SBI", ends with 1A hex)
  580.  04 - 23     Instrument Name (NULL terminated ASCII string).
  581.  24          Modulator Sound Characteristic
  582.  25          Carrier Sound Characteristic
  583.                         Bit 7   : Pitch Vibrato (AM)
  584.                         Bit 6   : Amplitude Vibrato (VIB)
  585.                         Bit 5   : Sustaining Sound (EG-TYP)
  586.                         Bit 4   : Envelope Scaling (KSR)
  587.                         Bit 3-0 : Frequency Multiplier (MULTIPLE)
  588.  26          Modulator Scaling/Output Level
  589.  27          Carrier Scaling/Output Level
  590.                         Bit 7-6 : Level Scaling (KSL)
  591.                         Bit 5-0 : Output Level (TL)
  592.  28          Modulator Attack/Decay
  593.  29          Carrier Attack/Decay
  594.                         Bit 7-4 : Attack Rate (AR)
  595.                         Bit 3-0 : Decay Rate (DR)
  596.  2A          Modulator Sustain Level/Release Rate
  597.  2B          Carrier Sustain Level/Release Rate
  598.                         Bit 7-4 : Sustain Level (SL)
  599.                         Bit 3-0 : Release Rate (RR)
  600.  2C          Modulator Wave Select
  601.  2D          Carrier Wave Select
  602.                         Bit 7-2 : All bits clear
  603.                         Bit 1-0 : Wave Select (WS)
  604.  2E          Feedback/Connection
  605.                         Bit 7-4 : all bits clear
  606.                         Bit 3-1 : Modulator Feedback (FB)
  607.                         Bit 0   : Connection
  608.  2F - 33     Reserved for future use
  609.  
  610.  
  611. ------------------------- that's all folks! ------------------------------
  612.  
  613. Everett
  614.  
  615. _______________________ Subj: VOC Compression Method _______________________
  616.  
  617. Fm: Bryant Bunderson 71742,1076                # 378740 
  618. To: All                                        Date: 18-Jun-93  15:43:46
  619.  
  620. I am trying to write a program to compress my PCM sound files to the 4 bit
  621. ADPCM format used in the Sound Blaster VOC files so they don't take up so
  622. they don't take up so much space. I have only been partially successful.
  623.  
  624. Does anyone out there have a specification or code fragment describing the
  625. compression algorithm used in 4 bit compressed VOC files?
  626.  
  627. I have seen a lot of technical know how in this forum and thought I would ask
  628. here. Any help would be appreciated.
  629.  
  630. Thanks, Bryant Bunderson
  631. ...........................................................................
  632.  
  633. Fm: Bryant Bunderson 71742,1076                # 379544 
  634. To: Andrew Amess 100141,1567                   Date: 19-Jun-93  23:25:44
  635.  
  636. Yes, the ADPCM method does lose information. It stands for Adaptive Delta
  637. Pulse Code Modulation. Basically instead of saving all the bits of a sample
  638. (PCM) it stores the difference or delta between two samples using fewer bits.
  639. Generally the fewer bits you use to represent the deltas the less the
  640. resulting wave looks like the original.
  641.  
  642. I need my compressed sound files to be compatible with the Sound Blaster VOC
  643. format so I really should use thier method of ADPCM compression but thanks
  644. for the response.
  645.  
  646. Bryant
  647. ...........................................................................
  648.  
  649. Fm: Patrick Reilly 71333,2764                  # 379632 
  650. To: Bryant Bunderson 71742,1076                Date: 20-Jun-93  03:20:04
  651.  
  652. Bryant,
  653.   I though the Sound Blaster used a modified form of ADPCM (I know that's
  654. what *my* code used <g>) - a sentinel value is used to allow the following
  655. word to be full (in this case) 8-bit. For example, using 3-bit encoding, 0-6
  656. are delta values; a 7 indicates that the decoder should grab the following
  657. full 8-bits and use this as an absolute value instead of a delta. If the
  658. system is designed right, you can get nice size savings; I had some 8-bit
  659. sound files that ended up being (average) about the same size using 2-bit;
  660. for 3-bit, they averaged about 2/3, etc. In fact, it varied so widely from
  661. file to file that I ended up using a file header and allowing different bit
  662. sizes. The decode program (read in .WAV files) would go through and try 2, 3,
  663. 4, 5, and 6-bit encoding; whoever came out smallest won; if they were all
  664. bigger (never happened) used a special header signature to show that it was a
  665. raw 8-bit data file...  Worked pretty well with PC-speaker sound library...
  666.         -Pat-
  667. ...........................................................................
  668.  
  669. Fm: Kirk Bateman 100112,71                     # 379643 
  670. To: Bryant Bunderson 71742,1076                Date: 20-Jun-93  05:57:22
  671.  
  672. I wouldn't use the ADPCM routine SB style to compress your SB data because
  673. the loss in quality is too great, look in the CLMFORUM under the Data
  674. Compression Section there is some interresting work there.
  675. ---Kirk/UK  
  676. ...........................................................................
  677.  
  678. Fm: Bryant Bunderson 71742,1076                # 380900 
  679. To: Patrick Reilly 71333,2764 (X)              Date: 21-Jun-93  18:45:14
  680.  
  681. I will look for a "sentinal bit" change in the data stream and see if I can
  682. determine if it is being used. I had come to the conclusion that they were
  683. doing something like that but didn't see a pattern. At least not a byte
  684. aligned pattern. Thanks for the help.
  685.  
  686. Bryant
  687.  
  688. P.S. Do your internal speaker routines work pretty well? I have pretty much
  689. crashed and burned every time I try to get intellagible playback through the
  690. internal speaker.
  691. ...........................................................................
  692.  
  693. Fm: Patrick Reilly 71333,2764                  # 381245 
  694. To: Bryant Bunderson 71742,1076 (X)            Date: 22-Jun-93  02:15:00
  695.  
  696. Bryant,
  697.   Sentinel value - I know that for *my* encoding/decoding, what I use for the
  698. sentinel value is the 'odd man out'. For example: with 4-bit encoding, this
  699. means that you have 1 sign bit and 3 'value' bits, for a range from +7 to -8.
  700. In this case, -8 is the sentinel value, and only +7..-7 are delta values (-8
  701. is 1000b).
  702.   Yeah, my speaker lib worked fine; I only ran it in the foreground though
  703. (actually, it ran in the background, but I used a while-loop to do nothing
  704. until the buffer finished playing). I would seriously think that there would
  705. be some files here on CIS that have a speaker driver...
  706.         -Pat-
  707. ...........................................................................
  708.  
  709. Fm: John W. Ratcliff 70253,3237                # 381154 
  710. To: Bryant Bunderson 71742,1076 (X)            Date: 21-Jun-93  23:30:31
  711.  
  712. An algorithm called ACOMP is in the public domain.  It was published in the
  713. July 1992 issue of DDJ.  It uses a special type of ADPCM that features a user
  714. selectable amount of loss, supports silence squelching, and provides
  715. extremely fast decompression speed.
  716.  
  717. Go DDJFORUM to find the source.
  718.  
  719. John.
  720. ...........................................................................
  721.